import java.util.Scanner;
public class Test {
    public static void main(String[] args) {
        Test test = new Test();

        //1.读入数据
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), q = in.nextInt();
        int[] nums = new int[n+1];
        for(int i = 1;i <= n;i++){
            nums[i] = in.nextInt();
        }

        //2.预处理一个前缀和数组
        long[] dp = new long[n+1];
        for(int i = 1;i <= n;i++){
            dp[i] = dp[i-1] + nums[i];
        }

        //3.
        while(q>0){
            int l = in.nextInt();
            int r = in.nextInt();
            System.out.print(dp[r] - dp[l-1]);
            q--;
        }
    }
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);

        int n ;
        int q ;
        System.out.println("Enter number: n and q ");
        n = in.nextInt();
        q = in.nextInt();
        long[] nums = new long[n+1];
        long[] nums2 = new long[n+1];
        int i = 1;
        int[][] groups = new int[q][2];
        int j = 0;
        int count = 0;

        // 注意 hasNext 和 hasNextLine 的区别
        //循环输入数组元素 和 前缀和数组元素
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            if(i>n){
                if(count == 0){
                    groups[j][0] = in.nextInt();
                    count++;
                }else{
                    groups[j][1] = in.nextInt();
                    j++;
                    count = 0;
                }
                continue;

            }
            nums[i] = in.nextInt();
            nums2[i] = nums2[i-1]+nums[i];
            i++;

        }
        i = 0;
        while (i<q){
            int l = groups[i][0];
            int r = groups[i][1];
            i++;
            //int sum = nums2[r] - nums2[l-1];
            //System.out.println(sum);
        }



    }
}




// 注意类名必须为 Main, 不要有任何 package xxx 信息
class Main {
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);

        int n ;
        int q ;
        System.out.println("Enter number: n and q ");
        n = in.nextInt();
        q = in.nextInt();
        int[] nums = new int[n+1];
        int[] nums2 = new int[n+1];
        int i = 1;
        int[][] groups = new int[q][2];
        int j = 0;
        int count = 0;

        // 注意 hasNext 和 hasNextLine 的区别
        //循环输入数组元素 和 前缀和数组元素
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            if(i>n){
                if(count == 0){
                    groups[j][0] = in.nextInt();
                    count++;
                }else{
                    groups[j][1] = in.nextInt();
                    j++;
                    count = 0;
                }

            }
            nums[i] = in.nextInt();
            nums2[i] = nums2[i-1]+nums[i];
            i++;

        }
        i = 0;
        while (i<q){
            int l = groups[i][0];
            int r = groups[i][1];
            i++;
            int sum = nums2[r] - nums2[l-1];
            System.out.println(sum);
        }



    }
}